home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / c / stik_dev / forecast / display.c < prev    next >
C/C++ Source or Header  |  1995-11-24  |  5KB  |  263 lines

  1. #include <aes.h>
  2. #include <vdi.h>
  3. #include <osbind.h>
  4. #include <math.h>
  5. #include <stdio.h>
  6.  
  7. #define PI    3.14159265358979323846
  8.  
  9. /* Prototypes... */
  10.  
  11.     void draw_template(void);
  12.     void draw_thermometer(short);
  13.     void draw_barometer(short, short);
  14.     void draw_humidity(short);
  15.     void draw_wind(char *, short);
  16.  
  17. /* Externals... */
  18.  
  19.     /* Prototypes... */
  20.     
  21.     /* Globals... */
  22.     
  23.         extern short    vdi_handle;
  24.         extern MFDB    work;
  25.  
  26. void draw_template(void)
  27.     {
  28.     void *oldlogbase;
  29.     short pxy[6], lpxy[4], i;    
  30.     short junk;
  31.     char    out[5];
  32.  
  33.     oldlogbase=Logbase();
  34.     Setscreen(work.fd_addr, (void *)-1, -1);
  35.  
  36. /* Thermometer */
  37.  
  38.     pxy[0]=15;
  39.     pxy[1]=15;
  40.     pxy[4]=pxy[2]=pxy[0];
  41.     pxy[5]=pxy[3]=pxy[1]+100;
  42.  
  43.     vsl_ends(vdi_handle, 2, 0);
  44.  
  45.     vsl_color(vdi_handle, 1);
  46.     vsl_width(vdi_handle, 7);
  47.     v_pline(vdi_handle, 2, pxy);
  48.     vsl_width(vdi_handle, 17);
  49.     v_pline(vdi_handle, 2, &pxy[2]);
  50.  
  51.     vsl_width(vdi_handle, 1);
  52.     lpxy[0]=15;
  53.     lpxy[2]=25;
  54.     vst_color(vdi_handle, 1);
  55.     vst_height(vdi_handle, 6, &junk, &junk, &junk, &junk);
  56.     for (i=5; i>0; i--)
  57.         {
  58.         lpxy[3]=lpxy[1]=115-(i*20);
  59.         v_pline(vdi_handle, 2, lpxy);
  60.         sprintf(out, "%d",  i*20);
  61.         v_gtext(vdi_handle, 30, 115-(i*20), out);
  62.         }
  63.  
  64.     vsl_color(vdi_handle, 0);
  65.     vsl_width(vdi_handle, 5);
  66.     v_pline(vdi_handle, 2, pxy);
  67.     vsl_width(vdi_handle, 15);
  68.     v_pline(vdi_handle, 2, &pxy[2]);
  69.  
  70.     vsl_color(vdi_handle, 2);
  71.     vsl_width(vdi_handle, 13);
  72.     v_pline(vdi_handle, 2, &pxy[2]);
  73.  
  74. /* Barometer */
  75.  
  76.     pxy[0]=57;
  77.     pxy[1]=108;
  78.     pxy[2]=83;
  79.     pxy[3]=122;
  80.  
  81.     vsf_color(vdi_handle, 1);
  82.     v_bar(vdi_handle, pxy);
  83.     pxy[0]++;
  84.     pxy[2]--;
  85.     pxy[3]--;
  86.     vsf_color(vdi_handle, 0);
  87.     v_bar(vdi_handle, pxy);    
  88.  
  89.     pxy[1]+=5;
  90.     vsf_color(vdi_handle, 8);
  91.     v_bar(vdi_handle, pxy);
  92.  
  93.     pxy[0]=70;
  94.     pxy[1]=15;
  95.     pxy[2]=pxy[0];
  96.     pxy[3]=pxy[1]+100;
  97.  
  98.     vsl_ends(vdi_handle, 2, 0);
  99.  
  100.     vsl_color(vdi_handle, 1);
  101.     vsl_width(vdi_handle, 7);
  102.     v_pline(vdi_handle, 2, pxy);
  103.  
  104.     vsl_width(vdi_handle, 1);
  105.     lpxy[0]=70;
  106.     lpxy[2]=80;
  107.     vst_color(vdi_handle, 1);
  108.     vst_height(vdi_handle, 6, &junk, &junk, &junk, &junk);
  109.     for (i=3; i>0; i--)
  110.         {
  111.         lpxy[3]=lpxy[1]=145-(i*40);
  112.         v_pline(vdi_handle, 2, lpxy);
  113.         sprintf(out, "%d",  i+28);
  114.         v_gtext(vdi_handle, 85, 145-(i*40), out);
  115.         }
  116.  
  117.     vsl_color(vdi_handle, 0);
  118.     vsl_width(vdi_handle, 5);
  119.     v_pline(vdi_handle, 2, pxy);
  120.  
  121. /* Hygrometer */
  122.  
  123.     vsl_color(vdi_handle, 1);
  124.     vsl_width(vdi_handle, 1);
  125.     v_gtext(vdi_handle, 108, 40, "0");
  126.     v_arc(vdi_handle, 150, 40, 32, 0, 1800);
  127.     v_gtext(vdi_handle, 185, 40, "100");
  128.  
  129. /* Anemometer */
  130.  
  131.     vsl_color(vdi_handle, 1);
  132.     vsl_width(vdi_handle, 1);
  133.     v_gtext(vdi_handle, 108, 120, "0");
  134.     v_arc(vdi_handle, 150, 120, 32, 0, 1800);
  135.     v_gtext(vdi_handle, 185, 120, "50");
  136.  
  137.     Setscreen(oldlogbase, (void *)-1, -1);
  138.     }
  139.  
  140. void draw_barometer(short p, short dec)
  141.     {
  142.     void *oldlogbase;
  143.     short pxy[4];
  144.     char out[8];
  145.  
  146.     pxy[2]=pxy[0]=70;
  147.     pxy[3]=115;
  148.     pxy[1]=65-(2*(100*p+dec-3000)/5);
  149.  
  150.     if (pxy[1]>115)    pxy[1]=115;
  151.     else if (pxy[1]<15) pxy[1]=15;
  152.  
  153.     vsl_color(vdi_handle, 8);
  154.     vsl_ends(vdi_handle, 0, 0);
  155.     vsl_width(vdi_handle, 3);
  156.  
  157.     sprintf(out, "%2.2d.%2.2d\"", p, dec);
  158.  
  159.     oldlogbase=Logbase();
  160.     Setscreen(work.fd_addr, (void *)-1, -1);
  161.     v_pline(vdi_handle, 2, pxy);
  162.     v_gtext(vdi_handle, 55, 140, "P(atm)");
  163.     v_gtext(vdi_handle, 55, 148, out);
  164.     Setscreen(oldlogbase, (void *)-1, -1);
  165.     }
  166.  
  167. void draw_thermometer(short temp)
  168.     {
  169.     void *oldlogbase;
  170.     short pxy[4];
  171.     char out[15];
  172.  
  173.     pxy[2]=pxy[0]=15;
  174.     pxy[3]=115;
  175.  
  176.     if (temp>100)        pxy[1]=15;
  177.     else if (temp<0)    pxy[1]=115;
  178.     else            pxy[1]=115-temp;
  179.  
  180.     vsl_color(vdi_handle, 2);
  181.     vsl_ends(vdi_handle, 0, 0);
  182.     vsl_width(vdi_handle, 3);
  183.  
  184.     sprintf(out, "%døF", temp);
  185.  
  186.     oldlogbase=Logbase();
  187.     Setscreen(work.fd_addr, (void *)-1, -1);
  188.     v_pline(vdi_handle, 2, pxy);
  189.     v_gtext(vdi_handle, 0, 140, "Temp");
  190.     v_gtext(vdi_handle, 0, 148, out);
  191.     Setscreen(oldlogbase, (void *)-1, -1);
  192.     }
  193.  
  194. void draw_humidity(short r)
  195.     {
  196.     void *oldlogbase;
  197.     float x,y;
  198.     short pxy[4];
  199.     short out[5];
  200.  
  201.     vsl_color(vdi_handle, 1);
  202.     vsl_ends(vdi_handle, 2, 1);
  203.     vsl_width(vdi_handle, 3);
  204.  
  205.     x=36*cos(((float)r*PI)/100);
  206.     y=36*sin(((float)r*PI)/100);
  207.  
  208.     if (x>36)    x=36;
  209.     else if (x<-36)    x=-36;
  210.     
  211.     if (y>36)    y=36;
  212.     else if (y<0)    y=0;
  213.  
  214.     pxy[0]=150;
  215.     pxy[1]=40;
  216.     pxy[2]=pxy[0]-(short)x;
  217.     pxy[3]=pxy[1]-(short)y;
  218.  
  219.     sprintf(out, "%d%", r);
  220.     
  221.     oldlogbase=Logbase();
  222.     Setscreen(work.fd_addr, (void *)-1, -1);
  223.     v_pline(vdi_handle, 2, pxy);
  224.     v_gtext(vdi_handle, 120, 50, "Humidity");
  225.     v_gtext(vdi_handle, 140, 58, out);
  226.     Setscreen(oldlogbase, (void *)-1, -1);
  227.     }
  228.  
  229. void draw_wind(char *dir, short r)
  230.     {
  231.     void *oldlogbase;
  232.     float x,y;
  233.     short pxy[4];
  234.     char out[10];
  235.  
  236.     vsl_color(vdi_handle, 1);
  237.     vsl_ends(vdi_handle, 2, 1);
  238.     vsl_width(vdi_handle, 3);
  239.  
  240.     x=36*cos(((float)r*PI)/50);
  241.     y=36*sin(((float)r*PI)/50);
  242.  
  243.     if (x>36)    x=36;
  244.     else if (x<-36)    x=-36;
  245.     
  246.     if (y>36)    y=36;
  247.     else if (y<0)    y=0;
  248.  
  249.     pxy[0]=150;
  250.     pxy[1]=120;
  251.     pxy[2]=pxy[0]-(short)x;
  252.     pxy[3]=pxy[1]-(short)y;
  253.  
  254.     sprintf(out, "%s at %d", dir, r);
  255.  
  256.     oldlogbase=Logbase();
  257.     Setscreen(work.fd_addr, (void *)-1, -1);
  258.     v_pline(vdi_handle, 2, pxy);
  259.     v_gtext(vdi_handle, 130, 140, "Winds");
  260.     v_gtext(vdi_handle, 110, 148, out);
  261.     Setscreen(oldlogbase, (void *)-1, -1);
  262.     }
  263.